fix: avoid wildcard names for anonymous generator functions#262
Merged
YunchuWang merged 4 commits intoJun 12, 2026
Merged
Conversation
Fix _getFunctionName fallback parser to handle generator functions and
arrow functions correctly:
- Return "" for arrow functions (no "function" keyword to parse)
- Skip "*" after "function" keyword in generator functions
- Guard against missing "(" in malformed input
Previously, anonymous generator functions registered under name "*",
silently passing validation but never matching scheduled orchestrations.
Update test helper in orchestration_executor.spec.ts to handle anonymous
inline orchestrators by falling back to addNamedOrchestrator.
Fixes #245
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
a17812f to
a94b9c0
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes function-name auto-detection in the worker Registry to prevent anonymous generator functions from being registered under the invalid wildcard name "*", addressing issue #245. This improves reliability of orchestrator/activity registration by ensuring truly-anonymous functions fail fast with the existing “non-empty name required” validation.
Changes:
- Hardened
Registry._getFunctionName()parsing to avoid returning"*"for anonymous generator functions and to return""for arrow functions. - Added unit tests covering named/anonymous functions, generators, async generators, and arrow functions for
_getFunctionName(). - Updated the orchestration executor test helper to provide a default orchestrator name when tests use anonymous inline orchestrators.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/durabletask-js/src/worker/registry.ts | Updates function-name fallback logic to avoid wildcard/garbage names for anonymous functions. |
| packages/durabletask-js/test/registry.spec.ts | Adds targeted tests for _getFunctionName() and validates addOrchestrator/addActivity behavior for anonymous functions. |
| packages/durabletask-js/test/orchestration_executor.spec.ts | Adjusts a shared test helper to handle anonymous orchestrators by registering a default name. |
Constrain Registry._getFunctionName() fallback parsing to leading function declarations so arrow function bodies containing nested functions do not produce bogus names. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the fallback parser regex with linear string parsing so function name detection only considers leading function signatures and avoids CodeQL polynomial-regex findings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Only fall back to a default orchestrator name when addOrchestrator fails with the expected missing-name validation error; rethrow unexpected registration failures. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
kaibocai
approved these changes
Jun 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #245